﻿/* ============================================================
   index-permit.css  –  Work Permits Page  (v4 – print fixed)
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Cairo:wght@400;600;700;800&display=swap');

:root {
    --green: #10b981;
    --green-dk: #047857;
    --green-lt: #d1fae5;
    --green-bg: #f0fdf4;
    --hot: #ef4444;
    --hot-lt: #fff1f1;
    --cold: #3b82f6;
    --cold-lt: #eff6ff;
    --txt: #1f2937;
    --txt2: #6b7280;
    --border: #e5e7eb;
    --white: #ffffff;
    --bg: #f3f4f6;
    --radius: 12px;
    --shadow: 0 1px 6px rgba(0,0,0,.08);
    --shadow-md: 0 4px 20px rgba(0,0,0,.10);
    --shadow-lg: 0 8px 32px rgba(0,0,0,.13);
}

*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html, body {
    overflow-x: hidden;
    font-family: 'Cairo', sans-serif;
}

/* ── Page ── */
.permits-page {
    max-width: 1400px;
    margin: 0 auto;
    padding: 24px 20px;
    background: var(--bg);
    min-height: 100vh;
    font-family: 'Cairo', sans-serif;
    width: 100%;
}

/* ── Header ── */
.page-header {
    text-align: center;
    margin-bottom: 24px;
    padding: 24px 20px;
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
    border-bottom: 4px solid var(--green);
}

.page-title {
    font-size: clamp(1.3rem, 3.5vw, 1.9rem);
    font-weight: 800;
    color: var(--green);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    flex-wrap: wrap;
}

.page-subtitle {
    color: var(--txt2);
    font-size: clamp(.8rem, 2vw, .95rem);
    margin-top: 7px;
}

/* ── Search ── */
.search-section {
    background: var(--white);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow-md);
    margin-bottom: 16px;
    width: 100%;
}

.search-section-title {
    font-size: .85rem;
    font-weight: 700;
    color: var(--green-dk);
    margin-bottom: 14px;
    display: flex;
    align-items: center;
    gap: 7px;
    padding-bottom: 11px;
    border-bottom: 1.5px solid var(--green-lt);
}

.search-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 14px;
}

.search-field label {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: .8rem;
    font-weight: 700;
    color: var(--green-dk);
    margin-bottom: 6px;
}

.f-input {
    display: block;
    width: 100%;
    border: 1.5px solid var(--border);
    border-radius: 9px;
    padding: 10px 13px;
    font-size: .88rem;
    background: #f9fafb;
    color: var(--txt);
    outline: none;
    transition: border-color .18s, background .18s, box-shadow .18s;
    appearance: none;
    -webkit-appearance: none;
    font-family: inherit;
}

    .f-input:focus {
        border-color: var(--green);
        background: var(--white);
        box-shadow: 0 0 0 3px rgba(16,185,129,.13);
    }

/* Searchable Dropdown */
.custom-select-wrap {
    position: relative;
    width: 100%;
}

.custom-select-trigger {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    border: 1.5px solid var(--border);
    border-radius: 9px;
    padding: 10px 13px;
    font-size: .88rem;
    background: #f9fafb;
    color: var(--txt);
    cursor: pointer;
    outline: none;
    transition: border-color .18s, box-shadow .18s;
    user-select: none;
    font-family: inherit;
    min-height: 42px;
}

    .custom-select-trigger .caret {
        font-size: .7rem;
        color: var(--txt2);
        transition: transform .2s;
        flex-shrink: 0;
        margin-right: 8px;
    }

.custom-select-wrap.open .custom-select-trigger {
    border-color: var(--green);
    background: var(--white);
    box-shadow: 0 0 0 3px rgba(16,185,129,.13);
}

.custom-select-wrap.open .caret {
    transform: rotate(180deg);
}

.custom-dropdown {
    display: none;
    position: absolute;
    top: calc(100% + 5px);
    right: 0;
    left: 0;
    z-index: 1050;
    background: var(--white);
    border: 1.5px solid var(--border);
    border-radius: 10px;
    box-shadow: var(--shadow-lg);
    overflow: hidden;
    animation: dropIn .15s ease;
}

@keyframes dropIn {
    from {
        opacity: 0;
        transform: translateY(-6px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.custom-select-wrap.open .custom-dropdown {
    display: block;
}

.dropdown-search-box {
    padding: 10px 10px 7px;
    border-bottom: 1px solid var(--border);
}

.dropdown-search-input {
    width: 100%;
    border: 1.5px solid var(--border);
    border-radius: 8px;
    padding: 8px 11px;
    font-size: .85rem;
    outline: none;
    background: #f9fafb;
    color: var(--txt);
    transition: border-color .18s;
    font-family: inherit;
    direction: rtl;
}

    .dropdown-search-input:focus {
        border-color: var(--green);
        background: var(--white);
    }

.dropdown-list {
    max-height: 220px;
    overflow-y: auto;
    padding: 5px;
}

    .dropdown-list::-webkit-scrollbar {
        width: 5px;
    }

    .dropdown-list::-webkit-scrollbar-thumb {
        background: var(--green-lt);
        border-radius: 10px;
    }

.dropdown-opt {
    padding: 9px 13px;
    font-size: .87rem;
    border-radius: 7px;
    cursor: pointer;
    color: var(--txt);
    transition: background .12s;
}

    .dropdown-opt:hover {
        background: var(--green-bg);
    }

    .dropdown-opt.selected {
        background: var(--green-lt);
        color: var(--green-dk);
        font-weight: 600;
    }

    .dropdown-opt.hidden {
        display: none;
    }

.dropdown-no-result {
    padding: 14px;
    text-align: center;
    color: var(--txt2);
    font-size: .84rem;
    display: none;
}

.search-actions {
    display: flex;
    gap: 10px;
    margin-top: 16px;
    flex-wrap: wrap;
}

.btn-search {
    flex: 1;
    min-width: 130px;
    background: var(--green);
    color: var(--white);
    border: none;
    border-radius: 9px;
    padding: 11px 22px;
    font-size: .9rem;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    transition: background .18s, transform .12s;
    font-family: inherit;
}

    .btn-search:hover {
        background: var(--green-dk);
        transform: translateY(-1px);
    }

.btn-reset {
    background: var(--white);
    border: 1.5px solid var(--border);
    border-radius: 9px;
    padding: 11px 20px;
    font-size: .88rem;
    color: var(--txt2);
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: border-color .18s, color .18s;
    white-space: nowrap;
}

    .btn-reset:hover {
        border-color: var(--green);
        color: var(--green);
    }

/* ── Create buttons ── */
.actions-section {
    margin-bottom: 18px;
}

.create-buttons {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.btn-create {
    min-width: 170px;
    padding: 12px 24px;
    border-radius: 10px;
    font-weight: 700;
    font-size: .92rem;
    color: var(--white);
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: opacity .18s, transform .15s, box-shadow .18s;
    box-shadow: 0 3px 12px rgba(0,0,0,.18);
}

    .btn-create:hover {
        opacity: .9;
        transform: translateY(-2px);
        color: var(--white);
    }

.btn-create-hot {
    background: linear-gradient(135deg, #ef4444, #dc2626);
}

.btn-create-cold {
    background: linear-gradient(135deg, #3b82f6, #2563eb);
}

/* ── Badges ── */
.badge-type {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 5px 11px;
    border-radius: 20px;
    font-weight: 700;
    font-size: .78rem;
    white-space: nowrap;
}

.badge-hot {
    background: var(--hot-lt);
    color: var(--hot);
}

.badge-cold {
    background: var(--cold-lt);
    color: var(--cold);
}

.status-pill {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 5px 12px;
    border-radius: 20px;
    font-weight: 700;
    font-size: .76rem;
    white-space: nowrap;
}

    .status-pill::before {
        content: '';
        width: 7px;
        height: 7px;
        border-radius: 50%;
        flex-shrink: 0;
    }

    .status-pill.active {
        background: var(--green-lt);
        color: var(--green-dk);
    }

        .status-pill.active::before {
            background: var(--green);
        }

    .status-pill.expired {
        background: #f1f5f9;
        color: #64748b;
    }

        .status-pill.expired::before {
            background: #94a3b8;
        }

/* ── Action buttons ── */
.btn-act {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    border-radius: 7px;
    font-weight: 600;
    font-size: .8rem;
    text-decoration: none;
    padding: 7px 12px;
    white-space: nowrap;
    transition: opacity .15s, transform .12s, box-shadow .12s;
    border: 1px solid transparent;
    cursor: pointer;
    font-family: inherit;
    line-height: 1.3;
}

    .btn-act:hover {
        opacity: .85;
        transform: translateY(-1px);
        box-shadow: 0 3px 8px rgba(0,0,0,.12);
    }

.btn-act-details {
    background: var(--green-lt);
    color: var(--green-dk);
    border-color: #a7f3d0;
}

.btn-act-edit {
    background: #fef3c7;
    color: #b45309;
    border-color: #fde68a;
}

.btn-act-print {
    background: #f1f5f9;
    color: #475569;
    border-color: #e2e8f0;
}

.action-btns-group {
    display: flex;
    gap: 5px;
    align-items: center;
    flex-wrap: nowrap;
}

/* ── Table Container ── */
.table-container {
    display: block;
    background: var(--white);
    border-radius: var(--radius);
    overflow: visible; /* ← مهم: ليس hidden */
    box-shadow: var(--shadow-md);
    margin-bottom: 24px;
    width: 100%;
}

.table-header-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 18px;
    background: var(--green-bg);
    border-bottom: 2px solid var(--green-lt);
    border-radius: var(--radius) var(--radius) 0 0;
}

    .table-header-bar h2 {
        font-size: .9rem;
        font-weight: 700;
        color: var(--green-dk);
        display: flex;
        align-items: center;
        gap: 7px;
        margin: 0;
    }

/* ── Header bar actions (print btn + count) ── */
.header-bar-actions {
    display: flex;
    align-items: center;
    gap: 14px;
}

.btn-print {
    background: linear-gradient(135deg, #10b981, #059669);
    color: white;
    border: none;
    padding: 9px 16px;
    border-radius: 10px;
    font-weight: 700;
    font-size: .85rem;
    cursor: pointer;
    transition: 0.2s ease;
    box-shadow: 0 4px 12px rgba(16,185,129,0.25);
    display: inline-flex;
    align-items: center;
    gap: 7px;
    font-family: 'Cairo', sans-serif;
}

    .btn-print:hover {
        transform: translateY(-2px);
        box-shadow: 0 7px 18px rgba(16,185,129,0.35);
    }

.count-block {
    display: flex;
    flex-direction: column;
    align-items: center;
    line-height: 1.25;
    min-width: 52px;
}

.count-number {
    font-size: 1.3rem;
    font-weight: 800;
    color: #1a5276;
    line-height: 1;
}

.count-label {
    font-size: .68rem;
    color: var(--txt2);
    font-weight: 600;
    white-space: nowrap;
}

/* ── Table scroll ── */
.table-scroll-wrap {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.permits-table {
    width: 100%;
    min-width: 900px;
    border-collapse: collapse;
    table-layout: auto;
}

    .permits-table th:nth-child(1) {
        min-width: 90px;
        white-space: nowrap;
    }

    .permits-table th:nth-child(2) {
        min-width: 140px;
        white-space: nowrap;
    }

    .permits-table th:nth-child(3) {
        min-width: 130px;
        white-space: nowrap;
    }

    .permits-table th:nth-child(4) {
        width: 99%;
    }

    .permits-table th:nth-child(5) {
        min-width: 110px;
        white-space: nowrap;
    }

    .permits-table th:nth-child(6) {
        min-width: 90px;
        white-space: nowrap;
    }

    .permits-table th:nth-child(7) {
        min-width: 260px;
        white-space: nowrap;
    }

    .permits-table th {
        padding: 13px 16px;
        text-align: right;
        font-weight: 700;
        font-size: .84rem;
        color: var(--green-dk);
        white-space: nowrap;
        background: var(--green-bg);
        border-bottom: 2px solid var(--green-lt);
    }

    .permits-table td {
        padding: 13px 16px;
        border-bottom: 1px solid #f1f5f9;
        font-size: .86rem;
        color: var(--txt);
        vertical-align: middle;
    }

        .permits-table td.td-desc {
            max-width: 200px;
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
        }

        .permits-table td.td-actions {
            white-space: nowrap;
            overflow: visible;
        }

    .permits-table tbody tr:last-child td {
        border-bottom: none;
    }

    .permits-table tbody tr:hover {
        background: #f7fffe;
    }

/* ── Empty state ── */
.empty-state {
    text-align: center;
    padding: 50px 20px;
    color: var(--txt2);
}

    .empty-state i {
        font-size: 2.8rem;
        color: #d1d5db;
        margin-bottom: 12px;
        display: block;
    }

    .empty-state p {
        font-size: .92rem;
    }

/* ── Mobile Cards ── */
.permits-cards {
    display: none;
    flex-direction: column;
    gap: 13px;
    margin-bottom: 20px;
}

.permit-card {
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    overflow: hidden;
    width: 100%;
    max-width: 100%;
}

    .permit-card.card-hot {
        border-top: 4px solid var(--hot);
    }

    .permit-card.card-cold {
        border-top: 4px solid var(--cold);
    }

.card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 11px 14px 8px;
    gap: 8px;
    flex-wrap: wrap;
}

.permit-card h6 {
    font-size: .9rem;
    font-weight: 700;
    color: var(--txt);
    padding: 0 14px 8px;
    line-height: 1.45;
    word-break: break-word;
}

.card-info {
    padding: 0 14px 12px;
    display: flex;
    flex-direction: column;
    gap: 5px;
}

    .card-info p {
        font-size: .83rem;
        color: var(--txt2);
        word-break: break-word;
    }

        .card-info p strong {
            color: var(--txt);
            font-weight: 600;
        }

.card-foot {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 7px;
    padding: 10px 12px 12px;
    border-top: 1px solid #f1f5f9;
    background: #fafafa;
}

    .card-foot .btn-act {
        flex-direction: column;
        gap: 4px;
        padding: 9px 4px;
        border-radius: 9px;
        font-size: .75rem;
        min-height: 52px;
        text-align: center;
        width: 100%;
    }

        .card-foot .btn-act i {
            font-size: .97rem;
        }

/* ── Responsive ── */
@media (max-width: 767px) {
    .table-container {
        display: none;
    }

    .permits-cards {
        display: flex;
    }

    .search-grid {
        grid-template-columns: 1fr;
    }

    .create-buttons {
        flex-direction: column;
    }

    .btn-create {
        min-width: unset;
        width: 100%;
    }

    .search-actions {
        flex-direction: column;
    }

    .btn-search, .btn-reset {
        width: 100%;
        justify-content: center;
    }
}

/* ================= LOCATION ================= */
.location-box {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.loc-item {
    font-size: 11px;
    padding: 3px 6px;
    background: #f8fafc;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
}

/* ================= MOBILE ================= */
@media (max-width: 768px) {
    .table-container {
        display: none;
    }

    .search-grid {
        grid-template-columns: 1fr;
    }
}

/* ================= PRINT (ONLY ONE CLEAN BLOCK) ================= */
@page {
    size: A4 landscape;
    margin: 10mm;
}

@media print {

    body {
        background: #fff !important;
        color: #000 !important;
        font-family: Cairo, Tahoma, Arial !important;
    }

    .search-section,
    .btn-search,
    .btn-reset,
    .action-btns-group,
    .btn-print {
        display: none !important;
    }

    .table-container {
        box-shadow: none !important;
        width: 100% !important;
    }

    .permits-table {
        font-size: 11px;
        width: 100% !important;
        border-collapse: collapse;
    }

        .permits-table th,
        .permits-table td {
            border: 1px solid #ccc !important;
            padding: 6px;
            text-align: center;
        }

    tr {
        page-break-inside: avoid;
    }

    .location-box {
        gap: 2px;
    }

    .loc-item {
        font-size: 10px !important;
        padding: 2px 5px !important;
    }

    i {
        display: none !important;
    }
}
@media print {
    body {
        font-family: 'Cairo', sans-serif !important;
    }
}
@media print {

    /* إظهار حالة التصريح بشكل واضح */
    .status-pill {
        display: inline-flex !important;
        padding: 3px 8px !important;
        border-radius: 4px !important;
        font-size: 10px !important;
        font-weight: 700 !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

        .status-pill.active {
            background: #d1fae5 !important;
            color: #065f46 !important;
            border: 1px solid #065f46 !important;
        }

        .status-pill.expired {
            background: #f3f4f6 !important;
            color: #6b7280 !important;
            border: 1px solid #6b7280 !important;
        }
}